package com.suqiu.common.exception;

import com.suqiu.common.result.IResultCode;
import com.suqiu.common.result.ResultCode;

/**
 * @author suqiu
 * @desc 业务异常统一封装
 */
public class SuqiuServiceException extends RuntimeException {
    private final IResultCode resultCode;

    public SuqiuServiceException(String message) {
        super(message);
        this.resultCode = ResultCode.FAILURE;
    }

    public SuqiuServiceException(IResultCode resultCode) {
        super(resultCode.getMessage());
        this.resultCode = resultCode;
    }

    public SuqiuServiceException(IResultCode resultCode, Throwable cause) {
        super(cause);
        this.resultCode = resultCode;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }

    public Throwable doFillInStackTrace() {
        return super.fillInStackTrace();
    }

    public IResultCode getResultCode() {
        return this.resultCode;
    }
}

